home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / ae / code / ax3.00 / assigned.c < prev    next >
Encoding:
C/C++ Source or Header  |  1980-01-03  |  1.4 KB  |  66 lines

  1. #include <exec/types.h>
  2. #include <libraries/dos.h>
  3. #include <libraries/dosextens.h>
  4. #include <libraries/filehandler.h>
  5. #include <clib/exec_protos.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <pragmas/dos_pragmas.h>
  10. #include <pragmas/exec_pragmas.h>
  11.  
  12. extern struct DosLibrary *DOSBase;
  13. STRPTR BstrOut(BSTR *bstr);
  14. void BstrC(BSTR *bstr,UBYTE *buf);
  15. int FindAssign(char *name);
  16. void Creds(void);
  17. void BstrC(BSTR *bstr,UBYTE *buf)
  18. {
  19.  UBYTE *str;
  20.  LONG loop,counter;
  21.  
  22.   counter=0;
  23.   str = (UBYTE*) BADDR(bstr);
  24.   for(loop=(LONG)str[0]; loop--; ++counter)
  25.   {
  26.    buf[counter] = str[counter+1];
  27.   }
  28.   buf[counter]='\0';
  29. }
  30.  
  31. STRPTR BstrOut(BSTR *bstr)
  32. {
  33.  UBYTE buf[256];
  34.  BstrC(bstr,buf);
  35.  return((char *)buf);
  36. }
  37.  
  38. int FindAssign(char *name)
  39. {
  40.  struct RootNode *rootnode;
  41.  struct DosInfo *dosinfo;
  42.  struct DeviceList *devicelist;
  43.  char temp[256];
  44.  register int i;
  45.  i=0;
  46.  strcpy(temp,name);
  47.  while(temp[i])
  48.  {
  49.    if(temp[i]==':') { temp[i]='\0'; i=-1; break; }
  50.    i++;
  51.  }
  52.  if(i!=-1) return(20);
  53.  rootnode = (struct RootNode*) DOSBase->dl_Root;
  54.  dosinfo  = (struct DosInfo*)  BADDR(rootnode->rn_Info);
  55.  devicelist = (struct DeviceList*) BADDR(dosinfo->di_DevInfo);
  56.  Forbid();
  57.   while(devicelist->dl_Next)
  58.   {
  59.    if(!stricmp((STRPTR)BstrOut(devicelist->dl_Name),temp)/* && devicelist->dl_Type!=DLT_DEVICE*/) { Permit(); return(0); }
  60.    devicelist = (struct DeviceList*) BADDR(devicelist->dl_Next);
  61.   }
  62.   Permit();
  63.   return(20);
  64. }
  65.  
  66.